" -------------------------- pluging setting ----------------------
au BufWrite *.py,*.cpp,*.h :Autoformat
let g:format_args = "-style=file"

" -------------------------- normal setting ----------------------
set nu
syntax on
set encoding=utf-8
colorscheme gruvbox
" colorscheme one
set background=dark    " Setting dark mode
"Credit joshdick
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
  if (has("nvim"))
    "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
    let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  endif
  "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  if (has("termguicolors"))
    set termguicolors
  endif
endif

" Give more space for displaying messages.
set cmdheight=2

set signcolumn=yes

set visualbell  " 禁止响铃"
set ruler       " 显示当前光标位置"
set autochdir   "当前目录随着被编辑文件的改变而改变"
set nocp        " 使用vim而非vi"
set cursorline

set autoindent    " 参考上一行的缩进方式进行自动缩进"
filetype indent on  " 根据文件类型进行缩进 "
set smarttab
set cindent         "c/c++自动缩进"
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=130
set expandtab
set autoindent
set fileformat=unix

autocmd FileType json syntax match Comment +\/\/.\+$+

" if hidden is not set, TextEdit might fail.
set hidden

" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup

" Better display for messages
" set cmdheight=2

" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300

" don't give |ins-completion-menu| messages.
set shortmess+=c

au BufNewFile,BufRead *.js,*.html,*.css
            \ set tabstop=2 |
            \ set softtabstop=2 |
            \ set shiftwidth=2 |


"设置文件编码，解决中文乱码问题"
if has("multi_byte")
    set fileencodings=utf-8,ucs-bom,cp936,cp1250,big5,euc-jp,euc-kr,latin1
else
    echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif

